package com.spring.mvc.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @version 1.0.0
 * @Date: 2022/7/11 21:04
 * @Author ZhuYouBin
 * @Description
 */
public class SecondInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("【SecondInterceptor】: 在Handler控制器之前，执行拦截器中的preHandler()方法......");
        // 放行,继续向后执行代码
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("【SecondInterceptor】: 在Handler控制器之后前，执行拦截器中的postHandle()方法......");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("【SecondInterceptor】: 视图渲染完成了，执行拦截器中的afterCompletion方法......");
    }

}
